package com.lanhe.admin.controller.user;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lanhe.common.core.controller.BaseController;
import com.lanhe.common.core.domain.AjaxResult;
import com.lanhe.common.utils.DateUtils;
import com.lanhe.identifier.domain.vo.UserStatVO;
import com.lanhe.identifier.service.ILhUserService;

/**
 * 用户(LhUser)表控制层
 *
 * @author zhanggl
 * @since 2023年09月22日03:22:14
 */
@RestController
@RequestMapping("lhUser")
public class LhUserController extends BaseController {

    /**
     * 服务对象
     */
    @Resource
    private ILhUserService lhUserService;

    /**
     * 统计注册人数
     */
    @GetMapping("/statRegister/{day}")
    public AjaxResult statRegister(@PathVariable("day") Integer day) {
        if (null == day  ||  day <=0)
        {
            day = 7;
        }
        List<UserStatVO> userStats = lhUserService.statRegister(day);
        for (UserStatVO userStat : userStats) {
            if (null != userStat.getDay() && userStat.getDay()>0){
                userStat.setDayStr(DateUtils.formattedDateStr(String.valueOf(userStat.getDay())));
            }
        }
        return success(userStats);
    }




}

